Required Software, Site Setup, and Database Connection
Before using this article, you must have the required software installed and define a site in Dreamweaver MX.
This article uses Dreamweaver MX 6.1 to create ASPX pages written in C#; IIS 5.0 to serve the pages; and either the Microsoft SQL Server 2000 Northwind sample database, or the Microsoft Access version of it.
If you haven’t done so already, download and install Dreamweaver MX, IIS version 5 or later, and the ASP.NET software development kit (SDK).
You have a choice between using the Microsoft SQL Server 2000 Northwind sample database, or the Microsoft Access version of it. The download archive contains the Microsoft Access version. If you use Microsoft SQL Server, you must have that installed as well.
Dreamweaver MX Site Definition
Use the following steps to define a site in Dreamweaver.
- Open Dreamweaver MX.
- Select Site > New Site… from the Menu bar to create a new site.
-
On the Basic tab, enter the following information, clicking Next at the bottom of each screen:
- Enter DataGridSamples in the Name field.
- Yes, I want to use a server technology. Select ASP.NET C# as the server technology.
- Edit and test locally, storing your files at C:\Inetpub\wwwroot\.
- URL to browse to the root of your site http://localhost/.
- No, do not copy files when I am done editing.
- Click Done to create an initial cache of your site.
Setting up the testing server
Open the the Site Definition dialog box by choosing Site > Edit Sites. Select your site's name from the list, and click the Edit button.
Set up the testing server to use ASP.NET C# as the Server Model. Set the Access and other values as appropriate for your site, as shown.
For more information about site setup, refer to the Dreamweaver MX documentation.
Creating the database connection
In this section, you select the SQL Server version of the Northwind sample database or the Microsoft Access version of it.
Microsoft SQL Server Connection—If you are using the Microsoft Access database contained in the downloadable sample files, skip to the Microsoft Access Connection section below. Use the following steps to create the Microsoft SQL Server Connection.
- Within Dreamweaver, select File > New… from the Menu bar to create a new file. On the General tab, select Dynamic Page for the Category and ASP.NET C# for the Dynamic Page type. Click the Create button to create the new page. This step is required because Dreamweaver needs to know what kind of server technology your pages will use before it can help you in the create a database connection
- Open the Databases tab of the Application panel group.
-
Click the plus button, and select the SQL Server Connection option. (Note that if you are working with an ASP JavaScript page, the options presented when you click the plus button are “Custom Connection String” and “Data Source Name (DSN).”
Figure 1. Creating a SQL Server database connection
Figure 2. SQL Server Connection Dialog
-
As shown above, when the SQL Server Connection dialog box appears, type in the information presented below, and ensure that it matches your database's User ID, password, and name.
Connection Name: Set this to Northwind.
Data Source: Set this to the name of your database server.
Initial Catalog: You will be using the Northwind sample database that comes with Microsoft SQL Server, so set this to Northwind.
User ID: The default user name for Microsoft SQL Server that is created at the time of installation is SA, so set this to SA.
Password: The default password for the SA account is blank, so leave this blank.
Note: In a production database, reset the password for the SA account for security reasons. Refer to the Microsoft SQL server documentation for more information. For more information on database security, see Ray West’s article Writing Secure Dreamweaver MX Applications and the DevNet Security Topic Center. If you have already done this, or have created another user account for the Northwind database, enter the appropriate User ID and Password.
- Click the Test button in the SQL Server Connection dialog to ensure that you set up your connection correctly. If an error occurs, check your Connection string settings.
- Next, click OK to accept the connection settings. You will now see the Northwind connection appear in the Databases tab of the Application panel group.
- Skip the Microsoft Access Connection section to the Observing the web.config file section below.
Microsoft Access Connection–If you are using Microsoft SQL Server, skip this section. To create the connection to the Microsoft Access Northwind database, use the following steps.
-
Within Dreamweaver, open the Application panel group, click the Databases tab, click the plus button, and select the OLE DB Connection option.
Figure 3. Creating a OLE DB database connection
- The OLE DB Connection dialog appears. Click the Build button.
- The Data Link Properties dialog appears. Click the Provider tab.
-
Select Microsoft Jet 4.0 OLE DB Provider from the list and click Next. If Microsoft Jet 4.0 OLE DB Provider is not in the list, you must install the ASP.NET software development kit (SDK), which includes this provider.
Figure 4. Data Link Properties dialog
- Click the ellipses (…) button and navigate to the location where you downloaded and unzipped the Northwind Microsoft Access Database, which the downloadable sample contains.
- Check the Blank Password checkbox.
-
Click the Test Connection button to test the connection to the database.
Figure 5. Data Link Properties dialog
- Click OK to close the Data Link Properties dialog.
- In the OLE DB Connection dialog, enter Northwind in the Connection Name field.
-
Click the Test button to test the connection.
Figure 6. OLD DB Connection dialog
- Click OK to save the OLE DB connection you created.
Observing the web.config file
Look at web.config in your site’s root directory. Notice that Dreamweaver
MX added several new lines under the <appSettings>
element:
<appSettings> element: <appSettings> <add key="MM_CONNECTION_HANDLER_Northwind" value="sqlserver.htm" /> <add key="MM_CONNECTION_STRING_Northwind" value="Persist Security Info=False; Data Source=NameOfYourDatabaseServer; Initial Catalog=Northwind;User ID=sa;Password=;" /> <add key="MM_CONNECTION_DATABASETYPE_Northwind" value="SQLServer" /> <add key="MM_CONNECTION_SCHEMA_Northwind" value="" /> <add key="MM_CONNECTION_CATALOG_Northwind" value="" /> </appSettings>
If you created an OLE DB Connection to the Access version of the Northwind database, the lines added to your web.config are:
<add key="MM_CONNECTION_HANDLER_Northwind2" value="default_oledb.htm" /> <add key="MM_CONNECTION_STRING_Northwind2" value="Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\Inetpub\wwwroot\Northwind.mdb;Persist Security Info=False" /> <add key="MM_CONNECTION_DATABASETYPE_Northwind2" value="OleDb" /> <add key="MM_CONNECTION_SCHEMA_Northwind2" value="" /> <add key="MM_CONNECTION_CATALOG_Northwind2" value="" />
You only have to perform this setup process once. From this point forward, Dreamweaver MX can use this connection.
In the next section, you will create the DataSet that you will use for the DataGrid data source.
Submit feedback on our tutorials, articles, and sample applications.